package com.atguigu.springcloud.controller;

import cn.hutool.core.util.IdUtil;
import com.atguigu.springcloud.entities.CommonResult;
import com.atguigu.springcloud.entities.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @PROJECT_NAME: cloud2020
 * @DESCRIPTION:
 * @Author: csc
 * @DATE: 2023/4/3 13:44
 */
@RestController
public class PaymentController {

    @Value("${server.port}")
    private String serverPort;



    public static Map<Integer, Payment> hashMap = new HashMap<>();
    static
    {
        hashMap.put(1,new Payment(1L, IdUtil.simpleUUID()));
        hashMap.put(2,new Payment(2L,IdUtil.simpleUUID()));
        hashMap.put(3,new Payment(3L,IdUtil.simpleUUID()));
    }

    @GetMapping("/paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id")Integer id){
        Payment payment = hashMap.get(id);
        CommonResult<Payment> result = new CommonResult<>(200,"from mysql serverport:"+serverPort,payment);
        return result;
    }//end




}
